/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package UDP;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

/**
 *
 * @author Antonio Pedro
 */
public class UDPReceiver {
    public static void main(String[] args) throws IOException {
        
        BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));
        
        //Porta de escuta
        DatagramSocket clientSocket = new DatagramSocket(2222);
        clientSocket.setBroadcast(true);
      
        byte[] receiveData = new byte[1024];

        DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);

        clientSocket.receive(receivePacket);
        String receivedString = new String(receivePacket.getData());

        System.out.println("Recebido...: " + receivePacket.getLength());
        clientSocket.close();
    }
}
